package com.bumblebee.server.model;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

/**
 * 
 * @author Dinesh
 * Represents a bill produced. A bill is a collection of items billed
 */
@Entity
public class Bill extends AbstractEntity{

	@ManyToOne
	private BillType type;
	
	@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
	@JoinColumn(name = "bill_id")
	private Set<BillItem> items;
	
	private Double grossAmount;
	
	private Double netAmount;
	
	private Double discountApplied;
	
	private BillStatus billStatus;

	@ManyToOne
	private Customer billTo;
	
	public Customer getBillTo() {
		return billTo;
	}

	public void setBillTo(Customer billTo) {
		this.billTo = billTo;
	}

	public BillType getType() {
		return type;
	}

	public void setType(BillType type) {
		this.type = type;
	}

	public Set<BillItem> getItems() {
		return items;
	}

	public void setItems(Set<BillItem> items) {
		this.items = items;
	}

	public Double getGrossAmount() {
		return grossAmount;
	}

	public void setGrossAmount(Double grossAmount) {
		this.grossAmount = grossAmount;
	}

	public Double getNetAmount() {
		return netAmount;
	}

	public void setNetAmount(Double netAmount) {
		this.netAmount = netAmount;
	}

	public Double getDiscountApplied() {
		return discountApplied;
	}

	public void setDiscountApplied(Double discountApplied) {
		this.discountApplied = discountApplied;
	}

	public BillStatus getBillStatus() {
		return billStatus;
	}

	public void setBillStatus(BillStatus billStatus) {
		this.billStatus = billStatus;
	}
	/**
	 * Adds this item to the current bill
	 * @param item
	 */
	public void addItemToBeBilled(BillItem item){
		this.items.add(item);
	}
	
}
